<?
$deletePlayerSccess = false;

if (isset($_GET['deletePlayerSccess'])) {
	$deletePlayerSccess = true;	
}
?>
<script>
var deleteFormSubmitted = false;
function submitDeleteForm(frm) {
	if (deleteFormSubmitted) {
		return;
	}
	for (i=0; i < document.getElementById("deleteSelectedPlayers").options.length;i++) {
		document.getElementById("deleteSelectedPlayers").options[i].selected = true;
	}
	
	deleteFormSubmitted = true;
	frm.submit();
}
var addFormSubmitted = false;
function submitAddForm(frm) {
	if (addFormSubmitted) {
		return;
	}
	if (frm.team.selectedIndex == -1) {
		alert("Need to select a team");
		return;
	}
	
	addFormSubmitted = true;
	frm.submit();
}
</script>
<form id="deletePlayerForm" action="../admin/submitDeletePlayers.php">
<input type="hidden" path="teamId" />
<table>
	<tr>
		<td><h2>Delete Players</h2></td>
	</tr>
	<tr>
		<td><input type="text" onkeyup="filterSelect(this.value, this.form, true)"></input></td>
	</tr>
	<tr>
		<td>
		<table>
		<tr>
		<td>
			<select name="availPlayers" size="20" style="width: 270px;">
			</select> 
		</td>
		<td align="top"><input type="button" value="Add" onclick="addNewPlayerToSelect(this.form, 'deleteSelectedPlayers')" class="buttonStyle"></td>
		<td>
		<select id="deleteSelectedPlayers" name="deleteSelectedPlayers[]" size=20 style="width: 270px;" multiple>
		</select>
		</td>
		</tr>
		<tr>
		<td colspan="3"><input type="button" value="Submit" onclick="submitDeleteForm(this.form)" class="buttonStyle" /></td>
		</tr>		
		</table>
		</td>
	</tr>
</table>
</form>
<form action="../admin/submitAddPlayers.php" method="post">
<table>
	<tr>
		<td><h2>Add Players</h2></td>
	</tr>
	<tr>
		<td><textarea name="newPlayers" rows="7" cols="30"></textarea></td>
	</tr>
	<tr>
		<td>
			<select name="team">
			    <option value="">Select...</option>
				<option value="HAWTHORN">Hawthorn</option>
				<option value="CARLTON">Carlton</option>
				<option value="MELBOURNE">Melbourne</option>
				<option value="FREMANTLE">Fremantle</option>
				<option value="WCE">West Coast</option>
				<option value="ESSENDON">Essendon</option>
				<option value="COLLINGWOOD">Collingwood</option>
				<option value="ADELAIDE">Adelaide</option>
				<option value="PORT_ADELAIDE">Port Adelaide</option>
				<option value="PSD">PSD Potentials</option>
				<option value="WESTERN_BULLDOGS">Western Bulldogs</option>
				<option value="ST_KILDA">St Kilda</option>
				<option value="SYDNEY">Sydney</option>
				<option value="BRISBANE">Brisbane</option>
				<option value="GEELONG">Geelong</option>
				<option value="NORTH_MELBOURNE">North Melbourne</option>
				<option value="RICHMOND">Richmond</option>
				<option value="GC">Gold Coast</option>
				<option value="GWS">Greater Western Sydney</option>
			</selext>
		</td>
	</tr>
	<tr>
		<td colspan="3"><input type="button" value="Submit" onclick="submitAddForm(this.form)" class="buttonStyle" /></td>
	</tr>
</table>
</form>
	</body>
</html>

<script>
populateSelect(document.getElementById("deletePlayerForm"), true);
<?if ($deletePlayerSccess) {?>
	alert("Successfully deleted!");
<?}?>
</script>